package com.gao.test;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnWebApplication
@EnableConfigurationProperties(ServiceProperties.class)
public class HelloAutoConfiguration {
    @Autowired
    ServiceProperties serviceProperties;
    //这样也就是相当于在向容器中装配HelloService的时候同时执行了此方法中的内容。
    @Bean
    public HelloService helloService(){
        HelloService helloService = new HelloService();
        helloService.setServiceProperties(serviceProperties);
        return helloService;
    }

    public static void main(String[] args) {
        HelloService helloService;

    }
}
